#include <stdio.h>
#include <stdlib.h>

void shuchu(int, int *);
void shuru(int, int *);
void shuchu2(int, int, int *);

int main()
{
    int m, n;
    int *array;
    scanf("%d", &n);
    array = (int*)calloc(n,sizeof(int));
    shuru(n, array);
    scanf("%d", &m);
    m = m % n;
    shuchu2(m, n, array);
    free(array);
    return 0;
}

void shuru(int n, int *array)
{
    int i = 0;
    for(; i<n; i++)
    {
        scanf("%d", &array[i]);
    }
}

void shuchu(int n, int *array)
{
    int i = 0;
    for (; i<n; i++)
    {
        printf("%d ", array[i]);
    }
}

void shuchu2(int m, int n, int *array)
{
    int i = n - m;
    int j = 0;
    for (; i<n; i++)
    {
        printf("%d ", array[i]);
    }
    for (; j<(n-m); j++)
    {
        printf("%d ", array[j]);
    }
}
